package com.zzyy.study.tenant;

import com.baomidou.mybatisplus.extension.plugins.handler.TenantLineHandler;

import net.sf.jsqlparser.expression.Expression;
import net.sf.jsqlparser.expression.LongValue;

/**
 * @auther zzyy
 * @create 2024-07-05 17:18
 */
public class CustomTenantHandler implements TenantLineHandler
{
    @Override
    public Expression getTenantId() {
        // 能够从租户上下文中获取当前租户信息
        String tenantId = TenantContextHolder.getCurrentTenantId();
        // 返回租户ID的表达式
        return new LongValue(tenantId);
    }

    @Override
    public String getTenantIdColumn() {
        return "tenant_id";
    }

    @Override
    public boolean ignoreTable(String tableName) {
        // 根据需要返回是否忽略该表
        return false;
    }
}